﻿using System;

namespace RoughHtml.w3c
{
    public interface DocumentHandler
    {

        /**
         * Receive notification of the beginning of a style sheet.
         *
         * The CSS parser will invoke this method only once, before any other
         * methods in this interface.
         *
         * @param uri The URI of the style sheet. @@TODO can be NULL ! (inline style sheet)
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.  
         */
        void startDocument(InputSource source)
            ;

        /**
         * Receive notification of the end of a document. 
         *
         * The CSS parser will invoke this method only once, and it will be the
         * last method invoked during the parse. The parser shall not invoke this
         * method until it has either abandoned parsing (because of an
         * unrecoverable error) or reached the end of input.  
         *
         * @param uri The URI of the style sheet.
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.  
         */
        void endDocument(InputSource source);

        /**
         * Receive notification of a comment.
         * If the comment appears in a declaration (e.g. color: /* comment * / blue;),
         * the parser notifies the comment before the declaration.
         *
         * @param text The comment.
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.  
         */
        void comment(String text);

        /**
         * Receive notification of an unknown rule t-rule not supported by this
         * parser.
         *
         * @param at-rule The complete ignored at-rule.
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.  
         */
        void ignorableAtRule(String atRule);

        /**
         * Receive notification of an unknown rule t-rule not supported by this
         * parser.
         *
         * @param prefix <code>null</code> if this is the default namespace
         * @param uri The URI for this namespace.
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.  
         */
        void namespaceDeclaration(String prefix, String uri)
        ;

        /**
         * Receive notification of a import statement in the style sheet.
         *
         * @param uri The URI of the imported style sheet.
         * @param media The intended destination media for style information.
         * @param defaultNamepaceURI The default namespace URI for the imported
         *                           style sheet.
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.
         */
        void importStyle(String uri, SACMediaList media,
                    String defaultNamespaceURI)
        ;

        /**
         * Receive notification of the beginning of a media statement.
         *
         * The Parser will invoke this method at the beginning of every media
         * statement in the style sheet. there will be a corresponding endMedia()
         * event for every startElement() event.
         *
         * @param media The intended destination media for style information.
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.  
         */
        void startMedia(SACMediaList media);

        /**
         * Receive notification of the end of a media statement.
         *
         * @param media The intended destination media for style information.
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.  
         */
        void endMedia(SACMediaList media);

        /**
         * Receive notification of the beginning of a page statement.
         *
         * The Parser will invoke this method at the beginning of every page
         * statement in the style sheet. there will be a corresponding endPage()
         * event for every startPage() event.
         *
         * @param name the name of the page (if any, null otherwise)
         * @param pseudo_page the pseudo page (if any, null otherwise)
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.  
         */
        void startPage(String name, String pseudo_page);

        /**
         * Receive notification of the end of a media statement.
         *
         * @param media The intended destination medium for style information.
         * @param pseudo_page the pseudo page (if any, null otherwise)
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.  
         */
        void endPage(String name, String pseudo_page);

        /**
         * Receive notification of the beginning of a font face statement.
         *
         * The Parser will invoke this method at the beginning of every font face
         * statement in the style sheet. there will be a corresponding endFontFace()
         * event for every startFontFace() event.
         *
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.
         */
        void startFontFace();

        /**
         * Receive notification of the end of a font face statement.
         *
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.  
         */
        void endFontFace();

        /**
         * Receive notification of the beginning of a rule statement.
         *
         * @param selectors All intended selectors for all declarations.
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.
         */
        void startSelector(SelectorList selectors);

        /**
         * Receive notification of the end of a rule statement.
         *
         * @param selectors All intended selectors for all declarations.
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.
         */
        void endSelector(SelectorList selectors);

        /**
         * Receive notification of a declaration.
         *
         * @param name the name of the property.
         * @param value the value of the property. All whitespace are stripped.
         * @param important is this property important ?
         * @exception CSSException Any CSS exception, possibly wrapping another
         *                         exception.
         */
        void property(String name, LexicalUnit value, bool important)
            ;
    }
}
